<template>
	<view class="mains">
		<view class="chongzhi">
			<div class="actives">
				<div class="left">
					<div>
						<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
							<h3>{{date}}</h3>
						</picker>

					</div>
					<div style="color: #999999;">
						提现 <span class="active">￥{{sum}}</span>
					</div>
				</div>
				<div class="right">

				</div>
			</div>
		</view>
		<view v-for="item in list " :key="item.id" class="actives">
			<div class="left">
				<div>
					<h3>{{item.customer_name}}</h3>
				</div>
				<div style="color: #999999;">
					{{item.create_time}}
				</div>
			</div>
			<div class="right">
				+{{item.amount}}
			</div>
		</view>
		<view class="isOver" v-if="flag">-----我是有底线的-----</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			// this.date=new Data
			this.agent_id = uni.getStorageSync('agent_id');
			// console.log(this.agent_id)
			this.name = wx.getStorageSync('nickName');
			this.token = wx.getStorageSync('token');
			console.log(this.token)
			this.tixianList()
		},
		data() {
			const currentDate = this.getDate({
				format: true,
			})
			return {
				listshow: "currentDate",
				date: currentDate,
				time: "",
				startDate: "2019-7-27",
				endDate: "2020-7-27",
				sum: '',
				target:'',
				flag:false,
				list: [],
				month: new Date().getMonth() + 1,
				request:false
			}
		},
		onReachBottom() {
			if(this.list.length<this.pageindex*10) return this.flag = true
			this.pageindex++
			this.bindDateChange
		},
		mounted() {},
		onReachBottom() {
			if (this.request) {
				this.getmoreNews()
				console.log("触底了222")
			}
		},
		methods: {
			onPullDown() {
				uni.startPullDownRefresh()
			},
			changes() {
				console.log("改变日期")
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				this.month = month
				return `${year}-${month}-${day}`;

			},
			 bindDateChange(e) {
				this.date = e.target.value
				console.log(this.date)
				let str = e.target.value.split('-',[3])
				console.log(str)
				let A = str[1]
				this.month =A
				this.tixianList()
			},
			 tixianList(){
				 this.$flyio.get('v1.Customer/getAgentCustomerApply', {
				 		agent_id: 13,
				 		page: 1,
				 		limit: 10,
						m:this.month
				 	}).then((ret) => {
				 		console.log(ret)
				 		this.list = ret.data.dataList
						this.sum = ret.data.sum
				 	})
				 	.catch((e) => {
				 		
				 	})
			},
		getmoreNews() {
				this.$flyio.get('v1.Customer/getAgentCustomerRangeLogList', {
						agent_id: 4,
						page: 1,
						limit: 10,
						m: this.month
					}).then((ret) => {
						if (ret.code == 0) {
								
							if (ret.data.data.length > 0) {
								this.page++
								this.newsList = this.list.concat(ret.data.data)
							} else {
								this.request = false
							}
						} else {}
						console.log(ret)
					})
					.catch((e) => {
						
					})
		
			},
		}
	}
</script>

<style scoped lang="scss">
	.active {
		color: red;
	}

	.mains {
		h3 {
			font-size: 30upx;
		}

		.chongzhi {}
	}

	.actives {
		display: flex;
		justify-content: space-between;
		height: 154upx;
		margin: 0 22upx;

		// background-color: green;
		border-bottom: 2upx solid #D3D3D3;

		.right {
			color: red;
			align-self: center;
		}

		.left {
			font-size: 22upx;

			h3 {
				font-size: 30upx;
			}

			align-self: center;
		}
	}
</style>
